<?php

namespace App;

use App\Models\AdminUser;
use App\Models\Department;
use Illuminate\Database\Eloquent\Model;

class Transaction extends Model
{
    protected $fillable = ['patent_sn', 'patent_name', 'patent_type_id', 'buyer', 'amount', 'type', 'date', 'contact_person', 'contact_mobile', 'user_id', 'department_id'];

    public function department()
    {
        return $this->belongsTo(Department::class);
    }

    public function user()
    {
        return $this->belongsTo(AdminUser::class, 'user_id');
    }

    public function patentApply()
    {
        return $this->hasOne(PatentApply::class, 'patent_sn', 'patent_sn');
    }

    public function patent()
    {
        return $this->belongsTo(Patent::class, 'patent_sn', 'patent_sn');
    }
}
